
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 06/07/2013 14:25:50
-- Generated from EDMX file: C:\Users\dimitris\Documents\Visual Studio 2012\Exam483\Main\DataAccess\EFModelFirst\TerritoriesModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [NorthwindModelFirst];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_RegionTerritory]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Territories] DROP CONSTRAINT [FK_RegionTerritory];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Regions]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Regions];
GO
IF OBJECT_ID(N'[dbo].[Territories]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Territories];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Regions'
CREATE TABLE [dbo].[Regions] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Description] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Territories'
CREATE TABLE [dbo].[Territories] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Description] nvarchar(max)  NOT NULL,
    [RegionId] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'Regions'
ALTER TABLE [dbo].[Regions]
ADD CONSTRAINT [PK_Regions]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Territories'
ALTER TABLE [dbo].[Territories]
ADD CONSTRAINT [PK_Territories]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [RegionId] in table 'Territories'
ALTER TABLE [dbo].[Territories]
ADD CONSTRAINT [FK_RegionTerritory]
    FOREIGN KEY ([RegionId])
    REFERENCES [dbo].[Regions]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_RegionTerritory'
CREATE INDEX [IX_FK_RegionTerritory]
ON [dbo].[Territories]
    ([RegionId]);
GO

INSERT [dbo].[Regions] ([Description]) VALUES (N'Eastern')
INSERT [dbo].[Regions] ([Description]) VALUES (N'Western')
INSERT [dbo].[Regions] ([Description]) VALUES (N'Northern')
INSERT [dbo].[Regions] ([Description]) VALUES (N'Southern')

INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Westboro                                          ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Bedford                                           ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Georgetow                                         ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Boston                                            ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Cambridge                                         ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Braintree                                         ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Providence                                        ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Hollis                                            ', 3)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Portsmouth                                        ', 3)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Wilton                                            ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Morristown                                        ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Edison                                            ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'New York                                          ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'New York                                          ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Mellvile                                          ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Fairport                                          ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'Philadelphia                                      ', 3)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'19713', N'Neward                                            ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'20852', N'Rockville                                         ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'27403', N'Greensboro                                        ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'27511', N'Cary                                              ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'29202', N'Columbia                                          ', 4)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'30346', N'Atlanta                                           ', 4)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'31406', N'Savannah                                          ', 4)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'32859', N'Orlando                                           ', 4)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'33607', N'Tampa                                             ', 4)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'40222', N'Louisville                                        ', 1)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'44122', N'Beachwood                                         ', 3)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'45839', N'Findlay                                           ', 3)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'48075', N'Southfield                                        ', 3)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'48084', N'Troy                                              ', 3)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'48304', N'Bloomfield Hills                                  ', 3)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'53404', N'Racine                                            ', 3)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'55113', N'Roseville                                         ', 3)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'55439', N'Minneapolis                                       ', 3)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'60179', N'Hoffman Estates                                   ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'60601', N'Chicago                                           ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'72716', N'Bentonville                                       ', 4)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'75234', N'Dallas                                            ', 4)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'78759', N'Austin                                            ', 4)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'80202', N'Denver                                            ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'80909', N'Colorado Springs                                  ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'85014', N'Phoenix                                           ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'85251', N'Scottsdale                                        ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'90405', N'Santa Monica                                      ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'94025', N'Menlo Park                                        ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'94105', N'San Francisco                                     ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'95008', N'Campbell                                          ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'95054', N'Santa Clara                                       ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'95060', N'Santa Cruz                                        ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'98004', N'Bellevue                                          ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'98052', N'Redmond                                           ', 2)
INSERT [dbo].[Territories] ([Description], [RegionId]) VALUES (N'98104', N'Seattle                                           ', 2)
-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------